package com.yanjiali.controller;

import com.yanjiali.model.R;
import com.yanjiali.feign.UserServiceFeign;
import com.yanjiali.model.resp.*;
import com.yanjiali.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Package: com.yanjiali.controller
 * @Author: yanjiali
 * @Created: 2025/4/18 21:52
 */
@Api("用户控制器")
@RestController
@RequestMapping("/v1/users")
public class UserController implements UserServiceFeign {

    @Autowired
    private UserService userService;

    @Override
    public R<ObtainTheUsernameThroughTheIdResp> obtainTheUsernameThroughTheId(Long userId) {
        return userService.obtainTheUsernameThroughTheId(userId);
    }

    @Override
    public R<GetTheBasicInformationOfTheUserByIDResp> getTheBasicInformationOfTheUserByID(Long userId) {
        return userService.getTheBasicInformationOfTheUserByID(userId);
    }

    @Override
    public R<GetTheBasicInformationOfTheUserByIDsResp> getTheBasicInformationOfTheUserByIDs(List<Long> userIds) {
        return userService.getTheBasicInformationOfTheUserByIDs(userIds);
    }

    @GetMapping("/getTheAvatar")
    @ApiOperation("通过用户名获取头像")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名")
    })
    public R<GetTheAvatarThroughTheUsernameResp> getTheAvatarThroughTheUsername(@RequestParam String username) {
        return userService.getTheAvatarThroughTheUsername(username);
    }

    @GetMapping("/getUserInfo")
    @ApiOperation("获取当前登录用户的基本信息")
    public R<GetTheBasicInformationOfTheCurrentUserResp> getTheBasicInformationOfTheCurrentUser() {
        return userService.getTheBasicInformationOfTheCurrentUser();
    }
}
